﻿@model Treinamento2015_01.Models.ProductViewModel

@{
    ViewBag.Title = Treinamento2015_01.Resources.General.Resource.Edit;
}
@Styles.Render("~/Content/Productcss.css")
<script type="text/javascript" src="~/Scripts/CurrencyFormatter.js"></script>
<h2>@Treinamento2015_01.Resources.General.Resource.Edit</h2>


@using (Html.BeginForm("Edit", "Product", FormMethod.Post, new { id = "signupform" }))
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>@Treinamento2015_01.Resources.Product.ResourceProduct.EditTitle</h4>
        <hr />
        @Html.ValidationSummary(true)
        @Html.HiddenFor(model => model.Id)
        <div class="form-group">
            @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.TextBoxFor(model => model.Name, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Name)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.ManufacturerId, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("ManufacturerId", (IEnumerable<SelectListItem>)ViewBag.Manufacturers, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.ManufacturerId)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">

                @Html.TextBoxFor(model => model.Price, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Price)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.ProductType, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @foreach (var item in ViewBag.TypeList)
                {
                    if (item.Id == Model.ProductType.Id)
                    {
                        <div class="col-md-2">
                            <a href="#" class="thumbnail typeitem selecionado" id="type-@item.Id">
                                <input type="radio" name="ProductTypeId" value="@item.Id" hidden checked><img class="TypeImage" src="@Url.Content(item.ImageUrl)"><div class="text-center">@item.Name</div>
                            </a>
                        </div>
                    }
                    else
                    {
                        <div class="col-md-2">
                            <a href="#" class="thumbnail typeitem" id="type-@item.Id">
                                <input type="radio" name="ProductTypeId" value="@item.Id" hidden><img class="TypeImage" src="@Url.Content(item.ImageUrl)"><div class="text-center">@item.Name</div>
                            </a>
                        </div>
                    }

                }
                <span id="message"><font color="red">@Treinamento2015_01.Resources.Product.ResourceProduct.ProductTypeAlert</font></span>
            </div>
        </div>

    </div>
    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="@Treinamento2015_01.Resources.General.Resource.Save" class="btn btn-default" />
        </div>
    </div>
}

<div>
    @Html.ActionLink(Treinamento2015_01.Resources.General.Resource.BackToList, "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval"),
    @Scripts.Render("~/Scripts/CheckBoxImages.js")

}
